<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>

    <!--<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />-->

    <title>大厅</title>
    <link type="text/css" rel="stylesheet" href="__STATIC__/game/css/style.css"/>

</head>

<body>

<div class="middlebox room_page">
    <div class="adv_box">
        <ul id="adv_box_ul">

        </ul>
        <img src="__STATIC__/game/img/trumpet.png" height="50%" class="trumpet"/>
    </div>

    <img src="__STATIC__/game/img/room_bg.jpg" class="room_page_bg"/>

    <section class="title clearfix">
        <img src="__STATIC__/game/img/room.png" height="22"/>

        <input type="text" name="room_name" class="room_name_input"/>
        <img src="__STATIC__/game/img/search.png" class="search"/>
    </section>

    <section class="room_list_section">
        <div class="room_list" style="text-align: center;font-size: 15px;width:100%">
            <div style="text-align: center;font-size: 15px;width:100%">系统关闭！</div>
        </div>

    </section>
</div>

<script src="__STATIC__/game/js/main.js"></script>
<script src="__STATIC__/game/js/config.js"></script>
<script>
    var user_uuid = "{$user.user_uuid}";
    var user_nick = "{$user.user_nick}";
    var user_name = "{$user.user_name}";
    var ws_protocal = 'ws://';
    var token = '{$user.token}';
    var is_close = {$site_status}
</script>
<script type="text/javascript" src="__STATIC__/game/js/jquery-2.0.0.min.js"></script>

<script type="text/javascript" src="__STATIC__/game/js/room.js"></script>
<script>

    $('.search').on('click', function () {
        if(!is_close){
            return false;
        }
        //去搜索

        var room_name = $.trim($('input[name=room_name]').val());
        if (!room_name) return false;

        getRoomList(room_name);

    });

    function getNoticeList() {
        var str = '';
        request(GV.url + 'Game/getNoticeList', {}, function (json) {


            if (json.ResponseStatus == 0) {
                var data = json.datas;
                for (var i in data) {
                    str += '<li>' + data[i]['content'] + '</li>';
                }
                $('#adv_box_ul').html(str)


            }
        });
    }

    function getRoomList(name) {
        var str = '';
        request(GV.url + 'Game/getRoomList', {token: token, room_name: name}, function (json) {
            if (json.ResponseStatus == 0) {
                var data = json.datas;
                for (var i in data) {
                    str += " <div class=\"room_list\" onclick=\"gotoRoom('" + data[i].room_uuid + "')\">" +
                        "<img src=\"__STATIC__/game/img/room_default_img.png\"/>" +
                        "<div>" + data[i].room_name + "<img src = \"__STATIC__/game/img/room_icon.png\" class= \"room_icon\"/> <br/>" +
                        "人数：" + data[i].clients + " 局数：" + data[i].round + " <br/>" +
                        "房号：" + data[i].room_id +
                        "</div>" +
                        "</div>"
                }
                $('.room_list_section').html(str);


            }

        })
    }

    function gotoRoom(room_id) {
        window.location.href = "/index/index/room/room_id/" + room_id
    }

    $(function () {
        getNoticeList();
        if (is_close) {
            getRoomList();
        }
    })
</script>
</body>

</html>